
s = {1, 2, 3, 4}
ss = set('1234')
print(type(s))
print(type(ss))


s.add(6)
print(s)
s.pop()
print(s)
s.remove(4)
print(s)


tuple = ()
print(tuple)
tuple2  = (1,"a", 3, "hello", 2.2)
print(tuple2)
tuple3 =(1,)
print(tuple3)



tuple = tuple('hello,world')
print(tuple)
list1 = ['Python','Java','C++', 'C']
tuple2 = tuple(list1)
print(tuple2)# # #修改元组元素
# t1 = (1, 2, 3)
# t2 = ('a', 'b', 'c')
# t3 = t1 + t2
# print(t3)
#
# t3 = (1, 2, 3, [4, 5, 6])
# del (t3)
# print(t3)


# # 任务
# # 使用input方法输入联系人姓名,电话,邮件,地址；
# # 定义单元组t1存储上述信息；
# # 输入t1，查看联系人信息；
n = input('请输入联系人姓名：')
t = input('请输入联系人电话：')
a = input('请输入联系人地址：')
t1 = ("姓名：", n, "电话： ", t, "邮箱：", e, "地址：", a)
print(t1)

# # 列表的创建
# 1.使用 【】 直接创建列表：
# 1.1 创建空列表
l1 = {}
print(l1)
l2 = [1, 2, "python", "jave"]
print(l2)
print(type(l2))
l3 = list()
print(l3)
l4 = list('Hello world')
print(l4)
t5 = tuple('hello')
print(t5)
l5 = list(t5)
print(l5)
l6 = list(range(5))
print(l6)

l7 = [1, 2, 3, 4, 'p', 'w', 'r']
print(l7[4])
print(l7[-2])

l8 = ['p', 'y', 't', 'h', 'o', 'n']
print(l8[2:5])
print(l8[:3])
print(l8[3:])
print(l8[1::2])
print(l8[-3:-1])
print(l8[::-1])

l9 = [1, 2, 3, 4, "python", "java", 'c']
for i in l9:
    print(i)

l10 = [10, 56, 34, 2, 56, 44, 7]
l10[2] = 100
print(l10)
l11 = [10, 56, 34, 2, 56, 44, 7]
l11[1: 4] = [45, -56, 98]
print(l11)

l12 = ['a', 'b', 'c']
l12.append('f')
print(l12)
l12.append(['e', 'f'])
print(l12)

l13 = ['a', 'b', 'c']
l13.index('d')
print(l13)
l13.extend('world')
print(l13)

l14 = ['python', 'c', java]
l14.insert(2, 'go')
print(l14)

# 删除元素
l15 = ['a', 'b', 'c', 'd', 'a']
l15.remove('b')
print(l15)

l16 = [10, 2, 4, 6, 8, 'a', ]
l16.pop(3)
print(l16)
# 删除最后一个元素
l15.pop()
print(l16)

# # del 可以用来删除列表中单个元素或者一段连续的元素
# l17 = ['a', 'b', 'c', 'd', 'e']
del l17[1]
print(l17)
l18 = [10, 56, 34, 2, 58, 44, 7]
del l18[1:4]
print(l18)
l17 = ['a', 'b', 2, 3, 5, 9]
del  l17[4]
print(l17)
del l17[1:3]
print(l17)
l19 = ['a', 'b', 'c', 'a']
l19.clear()
print(l19)
l18 = [6, 8, 'a', 0]
l18.clear()
print(l18)


# # 任务
# # 创建两个空列表name_list和phone_list，用于存储联系人姓名和电话；
# # 向列表中添加联系人信息；
# # 输入联系人编号修改信息；
# # 输入联系人编号删除信息；
# # # 使用clear()清空通讯录。name_list=['张三'， ’李四', '王五', ‘maliu'],phone_list=[123, 236, 258, 598]

nane_list = []
phone_list = []
while 1:
    print("菜单：1.添加联系人 2修改联系人 3.删除联系人 ")
    chioce = input("请输入选择：")
    if chice == "1":
        nane_list.append(input("请输入联系人姓名："))
        phone_list.append(input("请输入联系人手机号："))
        print(name_list)
        print(phone_list)
    elif chioce == "2":
        num = int(input("请输入联系人编号："))
        if len(name_list) > 0 and num <=len(name_list):
            name_list[num - 1] = input("修改联系人姓名")
            phone_list[num - 1] =input("修改联系人电话")
        else:
            print("联系人编号有误")
    #3.删除联系人信息
    elif chioce == "3":
        num = int(input("请输入联系人编号:"))
        if len(nane_list) > 0 and num <= len(name_list):
            name_list.pop(num-1)
            phone_list.pop(num-1)
        else:
            print("联系人编号输入有误")
    else:
        print("显示联系人信息")
        print(name_list)
        print(phone_list)




ls1 = [1, 5, 7, 'a', 'c', 'b', 6, 4, 1]
print(ls1.index('a'))
print(ls1.index('a',4))
print(ls1.index('c', 3, 7))
# print(ls1.index(2))


# # # count( ) 方法用来统计某个元素在列表中出现的次数 列表名.coun(统计的value元素）
# ls2 = [1, 3, 5, 7, 'a', 'b', 8, 3, 'b', 2, 5, 5, 7, 1]
# print(ls2.count(5))
# print(ls2.count(0))
# print(ls2.count('b'))
# #
ls2 = [1, 3, 5, 'a', 'b', 8, 3, 'b', 2, 5, 5, 7, 1]
print(ls2.count(8))
print(ls2.count(5))
print(ls2.count('f'))




ls3 = ['1', '3','44', '23', '99', '88', '56','233']
ls3.sort()
print(ls3)
ls3.sort(reverse=True)
print(ls3)
ls4 = [1,3,44,23,99,88,56,233]
ls4.sort()
print(ls4)
ls4.sort(reverse=True)
print(ls4)




"""字典"""
# 字典的创建
# 1,使用 {}创建字典语法模式：
# 字典名 = {’key1:'value1', 'key2':'value2',..., 'keyn':valuen}
# 使用字符串作为key
d1 = {'python': 90, "可视化": 89, "英语": 85}
print(type(d2))
# 使用元组和数字作为key
d2 = {(23, 89): "great", 30: [1, 3, 4]}
print(type(d2))
# 创建字典
d3 = {}
print(type(d3))
#
#
#
# 2, 用dict （） 方法通过关键字的参建字典格式:
